home *** CD-ROM | disk | FTP | other *** search
/ Mac Magazin/MacEasy 43 / Mac Magazin and MacEasy Magazine CD - Issue 43.iso / Software / Entwickler / CCMArea / Source / CCMEditField.cp < prev    next >
Encoding:
Text File  |  1998-02-10  |  2.1 KB  |  102 lines  |  [TEXT/CWIE]

  1. // CCMArea version 1.3.2
  2. // 2-10-98
  3. // by David Catmull
  4.  
  5. /* History:
  6.     
  7.     9-19-97        First version
  8.     
  9.     10-21-97    Removed AdjustCursorSelf
  10.     
  11.     12-22-97    ClickSelf checks CMClick's return value
  12.     
  13.     2-10-98        Only calls CMClick when active & enabled
  14. */
  15.  
  16. #include "UCMArea.h"
  17. #include "CCMEditField.h"
  18. #include "CCMWindow.h"
  19. #include <Appearance.h>
  20.  
  21. void
  22. CCMEditField::FinishCreateSelf()
  23. {
  24.     // Make sure mSuperCMArea is set.
  25.     
  26.     if (!mSuperCMArea) {
  27.         LView *superView;
  28.         
  29.         UCMArea::FindSuperCMArea(this,mSuperCMArea,superView);
  30.     }
  31. }
  32.  
  33. void
  34. CCMEditField::ClickSelf(const SMouseDownEvent &inMouseDown)
  35. {
  36.     // True from CMClick means go ahead and handle the event
  37.     
  38.     if (IsEnabled() && IsActive())
  39.         if (CMClick(inMouseDown) == cm_Nothing)
  40.             LEditField::ClickSelf(inMouseDown);
  41. }
  42.  
  43. void
  44. CCMEditField::GetSelectionDesc(AEDesc &outSelDesc)
  45. {
  46.     short start,end;
  47.     OSErr err;
  48.     
  49.     // Return either the current selection, or the entire text.
  50.     
  51.     start = (**mTextEditH).selStart;
  52.     end = (**mTextEditH).selEnd;
  53.     
  54.     if (end > start)
  55.         err = AECreateDesc(typeChar,*(**mTextEditH).hText+start,end-start,&outSelDesc);
  56.     else
  57.         err = AECreateDesc(typeChar,*(**mTextEditH).hText,(**mTextEditH).teLength,&outSelDesc);
  58. }
  59.  
  60.  
  61. void
  62. CCMEditField::BuildMenuSelf(MenuHandle inMenu)
  63. {
  64.     // You can just blindly call AddCommandToMenu for everything, since it
  65.     // checks to see if the commands are enabled. To override this, pass
  66.     // true for inOverrideDisable (it defaults to false).
  67.     
  68.     UCMArea::AddCommandToMenu(inMenu,cmd_Cut);
  69.     UCMArea::AddCommandToMenu(inMenu,cmd_Copy);
  70.     UCMArea::AddCommandToMenu(inMenu,cmd_Paste);
  71.     UCMArea::AddCommandToMenu(inMenu,cmd_SelectAll);
  72.     
  73. /* This is an example of how you would add a submenu
  74.  
  75.     ::AppendMenu(inMenu,"\pOther");
  76.     
  77.     mSubMenu = ::NewMenu(255,"\p");
  78.     
  79.     AddCommandToMenu(mSubMenu,cmd_About);
  80.     AddCommandToMenu(mSubMenu,cmd_Undo);
  81.     
  82.     ::InsertMenu(mSubMenu,hierMenu);
  83.     ::SetMenuItemHierarchicalID(inMenu,::CountMenuItems(inMenu),255);
  84. */
  85. }
  86.  
  87. void
  88. CCMEditField::CleanUpMenus()
  89. {
  90. /* If you had a submenu:
  91.     ::DeleteMenu(255);
  92.     ::DisposeMenu(mSubMenu);
  93. */
  94. }
  95.  
  96. void
  97. CCMEditField::PreClick(const SMouseDownEvent &inMouseDown)
  98. {
  99. #pragma unused (inMouseDown)
  100.     LCommander::SwitchTarget(this);
  101. }
  102.